package leetcode.dataStructure;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Thread1 implements Runnable {
    public static void main(String[] args) {
        Date startT = new Date(System.currentTimeMillis());
        while(true){
            try {
                Thread.sleep(1000);
                System.out.println(new SimpleDateFormat("HH:mm:ss").format(startT));
                startT = new Date(System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
//        try {
//            tenDown();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
    }

    //模拟倒计时
    public  void tenDown() throws InterruptedException {
        int num = 10;//10秒
        while (true) {
            Thread.sleep(200);
            System.out.println(num--);
            if (num <= 0) {
                break;
            }
        }
    }

    @Override
    public void run() {
    }
}
